#ifndef MATERIALEDITOR_H
#define MATERIALEDITOR_H

#include <QtGui/QDialog>
#include "ui_materialeditor.h"
#include "MaterialEditorStartup.h"
#include "MaterialProject.h"
#include <LitEditorMouse.h>
#include "LitScriptEngine.h"

namespace Lit
{
	namespace Editor
	{
		class MaterialEditor 
			: public QMainWindow
			, public Ogre::LogListener
			, public RenderWidgetListener
		{
			Q_OBJECT

			Material::Project *	mProject;
			RenderWidget *		mRenderer;
			Ogre::Log*			mLog;
			bool				mStandalone;
			DragInfos			mLeftDrag;
			Material::StartupDialog * mStartup;

		public:
			MaterialEditor(bool standalone, QWidget *parent = 0, Qt::WFlags flags = 0);
			~MaterialEditor();
			
			Material::Project * getProject();
			const Material::Project* getProject() const;

			void mousePressed(const QPoint& pos, Qt::MouseButtons btn);
			void mouseReleased(const QPoint& pos, Qt::MouseButtons btn );

			void panCamera( float dx, float dy );
			void tiltCamera(  float yaw, float pitch );
			void zoomCamera( Real factor );

			void mouseScrolled( int delta );
			bool isStandalone() const;

			void updateUi();
			void wheelEvent( QWheelEvent * evt );

			void closeEvent( QCloseEvent * evt );

		protected slots:
			bool frameStarted( const Ogre::FrameEvent &evt );

			void createScene();
			void destroyScene();

			void on_actionCompile_triggered();

			void on_actionNew_Project_triggered();
			void on_actionOpen_Project_triggered();
			void on_actionSave_Project_triggered();
			void on_actionSave_Project_As_triggered();
			void on_actionClose_Project_triggered();
			void on_actionExit_triggered();

		protected:
			void messageLogged( const Ogre::String &message, Ogre::LogMessageLevel lml, bool debugMask, const Ogre::String &filename );

		private:
			Ui::MaterialEditorClass ui;
		};
	};
};
#endif // MATERIALEDITOR_H
